package org.example.web.controller;

import org.example.domain.City;
import org.example.domain.County;
import org.example.domain.Province;
import org.example.service.ICityService;
import org.example.service.ICountyService;
import org.example.service.IProvinceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author 李新雨的项目86176
 * @version 1.0
 * @date 2024-12-05 22:42
 */
@Controller
public class ThreeController {

    @Autowired
    private IProvinceService provinceService;
    @Autowired
    private ICityService cityService;

    @Autowired
    private ICountyService countyService;



    @RequestMapping("/provinces")
    @ResponseBody
    public List<Province> getProvinces(){
        return provinceService.findAllProvince();
    }

    //通过省份id查询所有的城市
    @RequestMapping("/cities")
    @ResponseBody
    public List<City> getCities(Long pid){
       return cityService.findByProvinceId(pid);
    }
    //通过城市id查询所有的区域
    @RequestMapping("/areas")
    @ResponseBody
    public List<County> getAreas(Long cid){
        return countyService.findByCountyId(cid);
    }
}
